<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <script src="js/commons1.js"></script>
    <script src="js/jquery.cookie.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>个人信息</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="">
            <div style="padding-left:20px ;padding-bottom: 20px;">
                <label>【基本信息】</label>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>昵称：</label>
                </div>
                <div class="field l10">
                    <input id="name" type="text" class="input w100" value="" name="title"
                           data-validate="required:请输入标题"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>登录名：</label>
                </div>
                <div class="field l10">
                    <input id="loginName" type="text" class="input w100" value="" name="title"
                           data-validate="required:请输入标题"/>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>性别：</label>
                </div>
                <div class="field l10">
                    <select id="sex">
                        <option value="0">男</option>
                        <option value="1">女</option>
                        <option value="2">其他</option>
                    </select>

                    <div class="tips"></div>
                </div>
            </div>
            <ul class="list-inline" style="padding-left: 65px;  padding-bottom: 25px;">
                <li>电话:</li>
                <li style="padding-right: 200px;">
                    <div class="field">
                        <input id="tel" type="text" class="input" name="s_title" value="" data-validate="number:必须为数字"/>
                    </div>
                </li>
                <li>最后登陆时间:</li>
                <li style="padding-right: 200px;">
                    <div class="field">
                        <input id="lastLoginTime" type="datetime-local" class="input" name="s_title" value=""
                               style="padding:10px!important; height:auto!important;border:1px solid #ddd!important;"/>

                    </div>
                </li>
            </ul>

            <div class="field">
                <input id="submit" class="button bg-main icon-check-square-o" type="button" value="提交"
                       style="margin-left: 500px;">
            </div>
        </form>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            "url": "/user/getUserInf",
            "type": "POST",
            "dataType": "json",
            "contentType": "application/json; charset=utf-8",
            "success": function (resp) {
                $("#name").val(resp.userName)
                $("#loginName").val(resp.userRealName)
                $("#sex").val(resp.gender)
                $("#tel").val(resp.telPhone)
                $("#lastLoginTime").val(resp.lastLoginTime)
            }
        });
        $("#submit").click(function () {
            alert("hahah")
            var data = {
                "userName": $("#name").val(), "userRealName": $("#loginName").val(),
                "gender": $("#sex").val(), "telPhone": $("#tel").val(),
                "lastLoginTime": $("#lastLoginTime").val()
            }

            $.ajax({
                "url": "/user/change",
                "type": "POST",
                "data": JSON.stringify(data),
                "dataType": "json",
                "contentType": "application/json; charset=utf-8",
                "success": function (resp) {
                    if (resp.code == 0) {
                        location.href = "/html/index.html"
                    } else {
                        alert(resp.msg)
                    }
                }
            });
        });
    })
</script>
</body>
</html>